package com.tac.controller.mes;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.mes.ProductionCompletion;
import com.tac.service.mes.ProductionCompletionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/productionCompletion")
@CrossOrigin
@Api(tags = "制作执行MES--生产完工单")
public class ProductionCompletionController {

    @Autowired
    private ProductionCompletionService productionCompletionService;

    //生产完工单查询
    @ApiOperation("生产完工单查询")
    @GetMapping("/getList")
    public Result<PageInfo<ProductionCompletion>> getList(Integer pageNum, Integer pageSize, Integer productionPlanId, String productionOperation, Integer materialId,
                                                          @DateTimeFormat(pattern = "yyyy-MM-dd") Date completionDateStart, @DateTimeFormat(pattern = "yyyy-MM-dd")  Date completionDateEnd, String batchNumber, String status){
        return productionCompletionService.getList(pageNum,pageSize,productionPlanId, productionOperation,materialId,completionDateStart,completionDateEnd,batchNumber,status);
    }
    //生产完工单添加
    @ApiOperation("生产完工单添加")
    @PostMapping("/save")
    public Result save(@RequestBody ProductionCompletion productionCompletion){
        return productionCompletionService.save(productionCompletion);
    }
    //生产完工单删除
    @ApiOperation("生产完工单删除")
    @DeleteMapping("/remove")
    public Result remove(@RequestBody List<Integer> ids){
        return productionCompletionService.remove(ids);
    }
    //生产完工单更新
    @ApiOperation("生产完工单更新")
    @PutMapping("/update")
    public Result update(@RequestBody ProductionCompletion productionCompletion){
        return productionCompletionService.update(productionCompletion);
    }
}
